package com.pirestupppai.widgets.view;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.pirestupppai.R;
import com.pirestupppai.bean.TupaiUser;

/**
 * @author: xiaoluo
 * @date: 2017-04-13 15:33
 */
public class SingleRecommendView extends RelativeLayout {
    private Context mContext;

    private AvatarView mAvatar;
    private TextView mNickname;
    private TextView mDescTv;
    private ImageView mCloseBtn;
    private OnCloseRecommendListener mListener;

    public SingleRecommendView(Context context, OnCloseRecommendListener listener) {
        super(context);
        mContext = context;
        mListener = listener;
        initViews();
    }

    private void initViews() {
        LayoutInflater.from(mContext).inflate(R.layout.widget_single_recommend, this, true);
        mAvatar = (AvatarView) this.findViewById(R.id.feed_recommend_avatar);
        mNickname = (TextView) this.findViewById(R.id.feed_recommend_nickname);
        mDescTv = (TextView) this.findViewById(R.id.feed_recommend_desc);
        mCloseBtn = (ImageView) this.findViewById(R.id.feed_recommend_close_btn);
    }


    public void setData(TupaiUser user) {
        mAvatar.setAvatarImage(R.drawable.ic_zhanwei);
        mNickname.setText(user.getNickname());

        mCloseBtn.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                setVisibility(GONE);
                if (mListener != null) {
                    mListener.onClose();
                }
            }
        });
    }

    public interface OnCloseRecommendListener {
        void onClose();
    }


}
